Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional parameter for factorize to pass in original codes, uniques #1

Merged
merged 14 commits into from
Dec 11, 2023

Conversation

jonathanho168
Copy link
Collaborator

@jonathanho168 jonathanho168 commented Dec 11, 2023

Given original info:

Original Data: ['a', 'b', 'c', 'c', 'd', 'e']
Original Codes: [0 1 2 2 3 4] returned by pd.factorize(original_data)

new_data = ['a', 'd', 'e', 'k']
new_codes, new_uniques = pd.factorize(new_data)
new_codes1, new_uniques1 = pd.factorize(new_data, original_factorization=(original_uniques, original_codes))

new_codes will be 0123 (functionality of existing factorize function did not change)
new_codes1 will be 0345 (we can pass in optional parameter)

Copy link
Collaborator

@minjooki minjooki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@minjooki minjooki merged commit f1a84bb into main Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants